package com.gitee.swsk33.gatewaysendreceiver.api;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Enumeration;

@RestController
public class ReceiverAPI {

	@GetMapping("/hello")
	public String get() {
		return "请求成功转发到此！";
	}

	@GetMapping("/getheader")
	public String getHeader(HttpServletRequest request) {
		Enumeration<String> headers = request.getHeaderNames();
		while (headers.hasMoreElements()) {
			String name = headers.nextElement();
			System.out.println("键：" + name + " 值：" + request.getHeader(name));
		}
		return "已接收！";
	}

	@GetMapping("/getparam")
	public String getParam(@RequestParam("myparam") String param) {
		System.out.println(param);
		return "已接收！";
	}

	@GetMapping("/testResponse")
	public String response() {
		return "已接收！";
	}

}